<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, maximum-scale=1, initial-scale=1, user-scalable=yes">
    {php}echo app('seo')->buildHtml($vars);{/php}
    <link rel="shortcut icon" href=""/>
    <link rel="stylesheet" href="__STATIC__/cms/css/qietu.css">
    <link rel="stylesheet" href="__STATIC__/cms/font/iconfont.css">
    <link rel="stylesheet" href="__STATIC__/cms/css/header.css">
    <link rel="stylesheet" href="__STATIC__/cms/css/style.css">
    <link rel="stylesheet" href="__STATIC__/cms/css/responsive.css">
</head>

<body>


<div class="loginpage loginpage-bg">

    <div class="reg-wrap" style="height:auto">
        <form action="/register/regsave" id="reg" name="reg" autocomplete="off">
            <div class="head">
                <h2><img src="__STATIC__/cms/imgs/logo_3.png"/></h2>
                <h3>用户注册</h3>
            </div>
            <div class="body">
                <ul>
                    <li>
                        <i class="iconfont icon-yonghu"></i>
                        <input class="res-user" type="text" name="nickname" value="" id="account" placeholder="用户名昵称"/>
                    </li>
                    <li class="ver-btn">
                        <i class="iconfont icon-icon--"></i>
                        <input type="text" class="txt txt-code" name="mobile" id="mobile" value=""
                               placeholder="11位手机号码"/>
                        <a class="btn-code" href="javascript:;" onclick="getCode()">发送验证码</a>
                    </li>
                    <li>
                        <i class="iconfont icon-anquanbaozhang1"></i>
                        <input class="res-user" type="text" name="sms_code" placeholder="手机验证码"/>
                    </li>
                    <li>
                        <i class="iconfont icon-mima"></i>
                        <input class="res-password" type="password" name='password' placeholder="创建密码"/>
                    </li>
                    <li>
                        <i class="iconfont icon-mima"></i>
                        <input class="res-password" type="password" name='password_confirm' placeholder="确认密码"/>
                    </li>
                </ul>
                <div class="rule">
                    <label>
                        <input type="checkbox" name="agreement" id="rule" value="1" checked/>
                        <input type="hidden" name="safe_check_type" value="mobile"/>
                      <input type="hidden" name="invite_userid" value="">
                        <label for="rule"><i class="iconfont icon-queren"></i></label>
                        我已阅读并接受<a id="agreement" href="javascript:;"   style="color: #00b8b3;">《服务协议》</a>
                    </label>
                </div>
            </div>
            <div class="foot">
                <input type="button" class="btn" name="" id="regBtn" value="注 册"/>
                <p><a href="{:url('/ucenter/Foreign/login?module=merchant')}">有账号，去登录</a></p>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="__STATIC__/cms/js/jquery.js"></script>
<script type="text/javascript" src="__STATIC__/cms/js/getVerifyCode.js"></script>
<script type="text/javascript" src="__STATIC__/cms/js/script.js"></script>
<script src="__COMMON__/layer/layer.js"></script>
<script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>

<script type="text/javascript">
    var left_time = 60;
    $('#agreement').click(function () {
        layer.open({
            type: 2,
            title: '服务协议',
            area: ['70%', '80%'],
            anim: 2,
            content: ["{:url('/ucenter/Foreign/page',['name'=>'agreement'])}"]
        });
    });
    $('#regBtn').click(function () {
        layer.load();
        $.ajax({
            type: 'post',
            url: "{:url('/ucenter/Foreign/register',['module'=>'merchant'])}",
            data: $("#reg").serialize(),
            dataType: 'json',
            timeout: 3000,
            success: function (data) {
                layer.closeAll('loading');
                if (0 == data.code) {
                    layer.msg(data.message);

                    setTimeout(() => {

                        window.location.href = "{:url('login_merchant')}";
                        }, 3000);
                    // 跳转登录
                } else {
                    layer.msg(data.message);
                }
            },
            error: function (xhr, type) {
                layer.closeAll('loading');
                layer.msg(xhr.message);
            }
        })
    });

    function getCode() {
        if (left_time != 60) {
            layer.msg('请等待接收短信');
            return false;
        }
        var phone = $('#mobile').val();
        var reg = /\d{11}/;
        if (phone == '' || !reg.test(phone)) {
            layer.msg('请填写正确的手机号码！');
            $('#mobile').focus();
            return false;
        }
        if ({:config('setting.tencent_captcha_open')})
        {
            var captcha1 = new TencentCaptcha("{:config('setting.tencent_captcha_appid')}", function (res) {
                if (res.ret === 0) {
                    getSmsCode(res);
                }
            });
            captcha1.show(); // 显示验证码
        }
    else
        {
            getSmsCode({});
        }
    }

    function getSmsCode(res) {
        res['mobile'] = $('#mobile').val();
        res['type'] = 'register';
        res['__token__'] = '{:token()}';
        res['safe_check_type'] = 'mobile';
        $.ajax({
            type: 'post',
            url: "{:url('/ucenter/Foreign/sms')}",
            data: res,
            dataType: 'json',
            timeout: 3000,
            success: function (data) {
                if (0 == data.code) {
                    $("#TencentCaptcha").addClass('aui-hide');
                    layer.msg(data.message);
                    timeC();
                } else {
                    layer.msg(data.message);
                }
            },
            error: function (xhr, type) {
                layer.msg('异常');
            }
        })
    }

    function timeC() {
        if (left_time == 0) {
            left_time = 60;
            $('.btn-code').text('获取验证码');
        } else {
            left_time = left_time - 1;
            $('.btn-code').text(left_time);
            setTimeout('timeC()', 1000);
        }
    }

</script>


</body>
</html>

